package com.sx.util.date;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
	/**
	 * 
	 * 将date 转换成yyyy-MM-dd HH:mm:ss
	 * 
	 * */
	public static String getToday(Date date){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return sdf.format(date);
	}
	public static String getToday(){
		Date date = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return sdf.format(date);
	}
	/**
	 *根据参数返回
	 *当前年份+月份
	 *当前年份+周别 
	 *当前年份+月+日
	 **/
	public static String getDateName(String dayflag)
	{
		
		String str = "";
		if (dayflag.equals("month")) {
			//默认是返回当前月份
			str = "yyyy-MM";
			
		} else if(dayflag.equals("week")){
			//默认是返回当前周
			str = "yyyy-ww";
		}else {
			//默认是返回当前日期
			str = "yyyy-MM-dd";
		}
		SimpleDateFormat sdf = new SimpleDateFormat(str);
		String date = sdf.format(new Date());
		return date;
	}
}
